<%-- 
    Document   : addProdMgrAction
    Created on : Feb 24, 2012, 6:24:15 PM
    Author     : Hiroroi
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@page import="java.sql.*, DBConnection.*, UserPackage.*" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
         <%
            String fName, mName, lName, email, address, username, password, retypepass;
            boolean result, result3, result4;
            int j=0;
            username = request.getParameter("username");
            password = "test";
            //retypepass=request.getParameter("retypepass");
            fName = request.getParameter("fName");
            mName = request.getParameter("mName");
            lName = request.getParameter("lName");
          //  address = request.getParameter("Address");
            email = request.getParameter("eAdd");
            String hash = new Hasher().passHasher("password");
            
            inputChecker check = new inputChecker();
            if(check.stringCompare(username) && check.stringCompare(password) && check.stringCompare(fName) &&
               check.stringCompare(mName) && check.stringCompare(lName) &&
               check.emailCheck(email))
             {
          /*  username = username.replaceAll("[^a-zA-Z0-9@._]", "");
            password = password.replaceAll("[^a-zA-Z0-9@._]", "");
           // retypepass = retypepass.replaceAll("[^a-zA-Z0-9@._]", "");
           fName = fName.replaceAll("[^a-zA-Z0-9@._]", "");
            mName = mName.replaceAll("[^a-zA-Z0-9@._]", "");
            lName = lName.replaceAll("[^a-zA-Z0-9@._]", "");
            email = email.replaceAll("[^a-zA-Z0-9@._]", "");
            */

            User newUser = new User();

            //newUser.setAddress(address);
            newUser.setfName(fName);
            newUser.setmName(mName);
            newUser.setlName(lName);
            newUser.setEmail(email);
            newUser.setUsername(username);
            newUser.setPassword(password);
           // newUser.setRetypepass(retypepass);
            //newUser.setHash(hash);


            result = new UserManager().addProdMgr(newUser);
              //result2 = new UserManager().addLogIn(newUser);


           System.out.println(result);
           if(result == true){
               session.setAttribute("username", username);
                request.setAttribute("username", username);
                request.setAttribute("password", password);
                response.sendRedirect("userHomePage.jsp");
                           }
           }
            else
                response.sendRedirect("home.jsp");
           %>
    </body>
</html>
